<template>
	<view class="mainbgc">
		<header-top :messageInfo="{typeFlag:true,message:'历史详情',liner:false}"></header-top>
		<view class="zdymainpadding"  v-if="list.length">
			<view class="mainpadding flexbetween">
				<view class="titletext">客户名称</view>
				<view class="titletext">合计金额</view>
			</view>
		</view>
		<view class="ffffff zdymainpadding" v-if="list.length">
			<view class="zdymainpadding" v-for="item in list" :key="item.purchase_code" @click="jumpdetail(item)">
				<view class="flexbetween bottom-line">
					<view class="flexleft">
						<!-- 销售收款 -->
						<view v-if="item.type==1">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">销售收款</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.pay_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=销售金额：{{item.sales_money}}</view>
								<view class=" alltext">-预收款：{{item.advance}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">-欠款：{{item.arrears}}</view>
								<view class="alltext">-订货款：{{item.order_money}}</view>
							</view>
						</view>
						<!-- 退货单 -->
						<view v-if="item.type==2">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">退货款</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.retreat_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=退货金额：{{item.real_money}}</view>
								<view class=" alltext">-预收款：{{item.advance}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">-欠款：{{item.arrears}}</view>
							</view>
						</view>
						<!-- 收款单 -->
						<view v-if="item.type==3">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">收款单</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.pay_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=应收金额：{{item.write_off}}</view>
								<view class=" alltext">-预收款：{{item.advance}}</view>
							</view>
						</view>
						<!-- 预收款 -->
						<view v-if="item.type==4">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">预收款</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.pay_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=预收金额：{{item.real_money}}</view>
								<view class=" alltext">-欠款：{{item.arrears}}</view>
							</view>
						</view>
						<!-- 订货单 -->
						<view v-if="item.type==5">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">订货单</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.pay_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=订货金额：{{item.real_money}}</view>
								<view class=" alltext">-预收款：{{item.advance}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">-欠款：{{item.arrears}}</view>
							</view>
						</view>
						<!-- 费用支出 -->
						<view v-if="item.type==6">
							<view class="flexbetween">
								<view class="flexleft">
									<view class="xiaoshou">费用支出</view>
									<view class="chexiao" style="margin-left: 14rpx;" @click.stop="chexiao(item)">撤销</view>
								</view>
								<view class="qianshu">{{item.pay_money}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class="alltext">{{item.purchase_code}}</view>
								<view class="alltext">{{item.time_text}}</view>
							</view>
							<view class="flexleft" style="margin-top: 16rpx;">
								<view class=" alltext">=支出金额：{{item.real_money}}</view>
								<view class=" alltext">-欠款：{{item.arrears}}</view>
							</view>
						</view>
					</view>
					<view class="images">
						<image class="righticon2" src="../../../static/image/system/righticon2.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list:[],
				listid:"",
				dataAll:{}
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		methods: {
			init() {
				httpRequest.request('appapi/manage/finance/reconciliation_history_detail', 'POST', {
					id:this.listid
				}).then(res => {
					if (res.code == 1) {
						this.list = res.data.list
						this.dataAll = res.data
					} else {
						httpRequest.toast(res.msg)
					}
				}).catch(err => {
					httpRequest.toast(err.msg)
				})
			},
			// 撤销
			chexiao(item){
				let money = ""
				if(item.type==2){
					money = item.retreat_money
				}else{
					money = item.pay_money
				}
				httpRequest.request('appapi/manage/finance/reconciliation_cancel', 'POST', {
					recon_ids:this.dataAll.id,
					type:item.type,
					id:item.id,
					money:money
				}).then(res => {
					if (res.code == 1) {
						this.init()
					} else {
						httpRequest.toast(res.msg)
					}
				}).catch(err => {
					httpRequest.toast(err.msg)
				})
			},
			// 跳转详情
			jumpdetail(item){
				let type = item.type
				let purchase_code = item.purchase_code
				// 1=销售单,2=销货退货单,3=收款单,4=预收款单,5=订货单,6=费用支出
				if(type==1){//销售单
					uni.navigateTo({
						url: '/pages/workbench/xiaoshou/xiaoshoudd?purchase_code=' + purchase_code
					})
				}else if(type==2){
					uni.navigateTo({
						url: '/pages/workbench/xiaoshou/tuihuodan?purchase_code=' + purchase_code
					})
				}else if(type==3){
					// 客户结算详情
					uni.navigateTo({
						url: '/pages/workbench/caiwu/kehujsdetail?purchase_code=' + purchase_code
					})
				}else if(type==4){
					uni.navigateTo({
						url: '/pages/workbench/caiwu/kehuysk?purchase_code=' + purchase_code
					})
				}else if(type==5){
					uni.navigateTo({
						url: '/pages/workbench/caigou/dinghuod?purchase_code=' + purchase_code
					})
				}else if(type==6){
					uni.navigateTo({
						url: '/pages/workbench/xiaoshou/feiyonghetong?purchase_code=' + purchase_code
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.quanxuan {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
		margin-left: 14rpx;
	}

	.bianmatitle {
		font-size: 22rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.bottombox {
		padding: 38rpx 30rpx 80rpx;
		position: fixed;
		width: 100%;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
	}

	.daijiaoje {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
	}

	.shangjiaobtn {
		width: 198rpx;
		height: 62rpx;
		margin-left: 26rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #00B855;
		border-radius: 41rpx 41rpx 41rpx 41rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
	}

	.duiztitle {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.bgcs {
		padding-bottom: 200rpx;
	}

	.dingdqian {
		margin-left: 156rpx;
	}

	.box3 {
		margin-bottom: 16rpx;
	}

	.box2 {
		margin: 20rpx 0 16rpx;
	}

	.righticon2 {
		width: 13rpx;
		height: 20rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.alltext {
		width: 300rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.qianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #0BBDCB;
	}

	.daijiao {
		font-size: 22rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #F3AD3D;
		margin-left: 40rpx;
	}

	.xiaoshou {
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #000000;
	}

	.shoukuaant {
		padding: 30rpx 30rpx 20rpx;
		border-bottom: 1rpx solid rgba(0, 0, 0, .02);
	}

	.img {
		width: 40rpx;
		height: 40rpx;
	}

	/* // tab切换 */
	.selectbox {
		padding: 6rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #0BBDCB;
		line-height: 33rpx;
		background-color: #e1f4f5;
		border-radius: 30rpx;
		margin-right: 30rpx;
	}

	.noselectbox {
		padding: 6rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #999999;
		line-height: 33rpx;
		background-color: #eff0f0;
		border-radius: 30rpx;
		margin-right: 30rpx;
	}

	.selecttimetext {
		font-size: 24rpx;
		font-family: San Francisco Display-Medium, San Francisco Display;
		font-weight: 500;
		color: #666666;
		line-height: 24rpx;
	}

	.yuangbox {
		display: flex;
		align-items: center;
	}

	.ygbtn {
		margin: 16rpx 0 22rpx;
		background: rgba(153, 153, 153, .1);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		padding: 14rpx 120rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.ygtext {
		color: #666;
		font-weight: bold;
		font-size: 32rpx
	}

	.allbtn {
		width: 350rpx;
		height: 52rpx;
		border-radius: 50rpx;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
	}

	.lansebtn {
		color: #0BBDCB;
		background: rgba(11, 189, 203, .1);
	}

	.huisebtn {
		color: #999999;
		background: rgba(153, 153, 153, .1);
	}
	.boxsizing{
		box-sizing: border-box;
	}
	.bottom-line{
		padding: 30rpx 0;
		border-bottom: 1rpx solid  rgba(153, 153, 153, .1);
	}
	.zdymainpadding{
		padding: 0 30rpx;
	}
	.chexiao{
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
	}
</style>
